package com.siyuan.sns.user.dao.impl;

import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.siyuan.sns.user.dao.UserDao;
import com.siyuan.sns.user.domain.entity.User;
import com.siyuan.sns.utils.dao.BaseDao;

@Repository("userDao")
public class UserDaoImpl extends BaseDao implements UserDao {

	@Override
	public User findByUsername(String username) {
		Session session = this.getSession();
		return (User) session.createCriteria(User.class)
				.add(Restrictions.eq("username", username)).uniqueResult();
	}

}
